home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume11 / xsunclock / patch1 next >
Encoding:
Internet Message Format  |  1991-02-14  |  45.5 KB

  1. Path: uunet!elroy.jpl.nasa.gov!sdd.hp.com!spool.mu.edu!sol.ctr.columbia.edu!lll-winken!sun-barr!newstop!exodus!agd.fhg.de!pfuetz
  2. From: pfuetz@agd.fhg.de
  3. Newsgroups: comp.sources.x
  4. Subject: v11i079: xsunclock - enhacned oclock, Patch1, Part01/01
  5. Message-ID: <8026@exodus.Eng.Sun.COM>
  6. Date: 15 Feb 91 08:03:03 GMT
  7. References: <csx-11i079:xsunclock@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 1467
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: pfuetz@agd.fhg.de
  13. Posting-number: Volume 11, Issue 79
  14. Archive-name: xsunclock/patch1
  15. Patch-To: xsunclock: Volume XXX, Issue XXX
  16.  
  17. Hello!
  18.  
  19. This is a two part posting. I added the sound option that were included in 
  20. "oclock" by Mike Wagner (wagner@cadillac.siemens.com) to xclock.
  21. Please refer to the manual page for former information.
  22.  
  23. Matthias Pfuetzner
  24.  
  25. #!/bin/sh
  26. # To unshare, sh or unshar this file
  27. echo CHANGES 1>&2
  28. sed -e 's/^X//' > CHANGES <<'E!O!F! CHANGES'
  29. XThe following changes have been made to this directory since R3:
  30. X
  31. X     o    added icon mask.
  32. X     o    added WM_DELETE_WINDOW.
  33. X     o    removed vendor shell hack now that Xaw does correctly.
  34. X
  35. XThe following changes were done by Matthias Pfuetzner
  36. Xpfuetzner@agd.fhg.de:
  37. X
  38. X     o  added the sound option that were included in "oclock"
  39. E!O!F! CHANGES
  40. echo Clock.c 1>&2
  41. sed -e 's/^X//' > Clock.c <<'E!O!F! Clock.c'
  42. X#ifndef lint
  43. Xstatic char Xrcsid[] = "$XConsortium: Clock.c,v 1.50 89/12/06 15:23:24 kit Exp $";
  44. X#endif /* lint */
  45. X
  46. X
  47. X/***********************************************************
  48. XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  49. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  50. X
  51. X                        All Rights Reserved
  52. X
  53. XPermission to use, copy, modify, and distribute this software and its 
  54. Xdocumentation for any purpose and without fee is hereby granted, 
  55. Xprovided that the above copyright notice appear in all copies and that
  56. Xboth that copyright notice and this permission notice appear in 
  57. Xsupporting documentation, and that the names of Digital or MIT not be
  58. Xused in advertising or publicity pertaining to distribution of the
  59. Xsoftware without specific, written prior permission.  
  60. X
  61. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  62. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  63. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  64. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  65. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  66. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  67. XSOFTWARE.
  68. X
  69. X******************************************************************/
  70. X
  71. X#include <X11/Xlib.h>
  72. X#include <X11/StringDefs.h>
  73. X#include <X11/IntrinsicP.h>
  74. X#include <X11/Xaw/XawInit.h>
  75. X#include "ClockP.h"
  76. X
  77. Xextern long time();
  78. Xstatic void clock_tic(), DrawHand(), DrawSecond(), SetSeg(), DrawClockFace();
  79. Xstatic erase_hands(), round();
  80. X    
  81. X/* Private Definitions */
  82. X
  83. X#define VERTICES_IN_HANDS    6    /* to draw triangle */
  84. X#define PI            3.14159265358979
  85. X#define TWOPI            (2. * PI)
  86. X
  87. X#define SECOND_HAND_FRACT    90
  88. X#define MINUTE_HAND_FRACT    70
  89. X#define HOUR_HAND_FRACT        40
  90. X#define HAND_WIDTH_FRACT    7
  91. X#define SECOND_WIDTH_FRACT    5
  92. X#define SECOND_HAND_TIME    30
  93. X
  94. X#define ANALOG_SIZE_DEFAULT    164
  95. X
  96. X#define max(a, b) ((a) > (b) ? (a) : (b))
  97. X#define min(a, b) ((a) < (b) ? (a) : (b))
  98. X#define abs(a) ((a) < 0 ? -(a) : (a))
  99. X
  100. X
  101. X/* Initialization of defaults */
  102. X
  103. X#define offset(field) XtOffset(ClockWidget,clock.field)
  104. X#define goffset(field) XtOffset(Widget,core.field)
  105. X
  106. Xstatic XtResource resources[] = {
  107. X    {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),
  108. X    goffset(width), XtRImmediate, (caddr_t) 0},
  109. X    {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension),
  110. X    goffset(height), XtRImmediate, (caddr_t) 0},
  111. X    {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
  112. X    goffset(background_pixel), XtRString, "XtdefaultBackground"},
  113. X    {XtNupdate, XtCInterval, XtRInt, sizeof(int), 
  114. X        offset(update), XtRImmediate, (caddr_t) 60 },
  115. X    {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
  116. X        offset(fgpixel), XtRString, "XtdefaultForeground"},
  117. X    {XtNhand, XtCForeground, XtRPixel, sizeof(Pixel),
  118. X        offset(Hdpixel), XtRString, "XtdefaultForeground"},
  119. X    {XtNhighlight, XtCForeground, XtRPixel, sizeof(Pixel),
  120. X        offset(Hipixel), XtRString, "XtdefaultForeground"},
  121. X    {XtNanalog, XtCBoolean, XtRBoolean, sizeof(Boolean),
  122. X        offset(analog), XtRImmediate, (caddr_t) TRUE},
  123. X    {XtNchime, XtCBoolean, XtRBoolean, sizeof(Boolean),
  124. X    offset(chime), XtRImmediate, (caddr_t) FALSE },
  125. X    {XtNpadding, XtCMargin, XtRInt, sizeof(int),
  126. X        offset(padding), XtRImmediate, (caddr_t) 8},
  127. X    {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
  128. X        offset(font), XtRString, "fixed"},
  129. X    {XtNreverseVideo, XtCReverseVideo, XtRBoolean, sizeof (Boolean),
  130. X    offset (reverse_video), XtRImmediate, (caddr_t) FALSE},
  131. X    {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int),
  132. X        offset (backing_store), XtRString, "default"},
  133. X    {XtNhourSound, XtCHourSound, XtRString, sizeof (String),
  134. X       offset (hour_sound), XtRString, NULL},
  135. X    {XtNquarterPastSound, XtCQuarterPastSound, XtRString, sizeof (String),
  136. X       offset (quarter_past_sound), XtRString, NULL},
  137. X    {XtNhalfPastSound, XtCHalfPastSound, XtRString, sizeof (String),
  138. X       offset (half_past_sound), XtRString, NULL},
  139. X    {XtNquarterOfSound, XtCQuarterOfSound, XtRString, sizeof (String),
  140. X       offset (quarter_of_sound), XtRString, NULL},
  141. X    {XtNchimeSound, XtCChimeSound, XtRString, sizeof (String),
  142. X       offset (chime_sound), XtRString, NULL},
  143. X    {XtNvolume, XtCVolume, XtRInt, sizeof (int),
  144. X       offset (volume), XtRString, NULL},
  145. X};
  146. X
  147. X#undef offset
  148. X#undef goffset
  149. X
  150. Xstatic void ClassInitialize();
  151. Xstatic void Initialize(), Realize(), Destroy(), Resize(), Redisplay();
  152. Xstatic Boolean SetValues();
  153. X
  154. XClockClassRec clockClassRec = {
  155. X    { /* core fields */
  156. X    /* superclass        */    &widgetClassRec,
  157. X    /* class_name        */    "Clock",
  158. X    /* widget_size        */    sizeof(ClockRec),
  159. X    /* class_initialize        */    ClassInitialize,
  160. X    /* class_part_initialize    */    NULL,
  161. X    /* class_inited        */    FALSE,
  162. X    /* initialize        */    Initialize,
  163. X    /* initialize_hook        */    NULL,
  164. X    /* realize            */    Realize,
  165. X    /* actions            */    NULL,
  166. X    /* num_actions        */    0,
  167. X    /* resources        */    resources,
  168. X    /* resource_count        */    XtNumber(resources),
  169. X    /* xrm_class        */    NULL,
  170. X    /* compress_motion        */    TRUE,
  171. X    /* compress_exposure    */    TRUE,
  172. X    /* compress_enterleave    */    TRUE,
  173. X    /* visible_interest        */    FALSE,
  174. X    /* destroy            */    Destroy,
  175. X    /* resize            */    Resize,
  176. X    /* expose            */    Redisplay,
  177. X    /* set_values        */    SetValues,
  178. X    /* set_values_hook        */    NULL,
  179. X    /* set_values_almost    */    XtInheritSetValuesAlmost,
  180. X    /* get_values_hook        */    NULL,
  181. X    /* accept_focus        */    NULL,
  182. X    /* version            */    XtVersion,
  183. X    /* callback_private        */    NULL,
  184. X    /* tm_table            */    NULL,
  185. X    /* query_geometry           */    XtInheritQueryGeometry,
  186. X    /* display_accelerator      */    XtInheritDisplayAccelerator,
  187. X    /* extension                */    NULL
  188. X    }
  189. X};
  190. X
  191. XWidgetClass clockWidgetClass = (WidgetClass) &clockClassRec;
  192. X
  193. X/****************************************************************
  194. X *
  195. X * Private Procedures
  196. X *
  197. X ****************************************************************/
  198. X
  199. Xstatic void ClassInitialize()
  200. X{
  201. X    XawInitializeWidgetSet();
  202. X    XtAddConverter( XtRString, XtRBackingStore, XmuCvtStringToBackingStore,
  203. X            NULL, 0 );
  204. X}
  205. X
  206. X/* ARGSUSED */
  207. Xstatic void Initialize (request, new)
  208. X    Widget request, new;
  209. X{
  210. X    ClockWidget w = (ClockWidget)new;
  211. X    XtGCMask        valuemask;
  212. X    XGCValues    myXGCV;
  213. X    int min_height, min_width;
  214. X
  215. X    valuemask = GCForeground | GCBackground | GCFont | GCLineWidth;
  216. X    if (w->clock.font != NULL)
  217. X        myXGCV.font = w->clock.font->fid;
  218. X    else
  219. X        valuemask &= ~GCFont;    /* use server default font */
  220. X
  221. X    min_width = min_height = ANALOG_SIZE_DEFAULT;
  222. X    if(!w->clock.analog) {
  223. X       char *str;
  224. X       struct tm tm, *localtime();
  225. X       long time_value;
  226. X       (void) time(&time_value);
  227. X       tm = *localtime(&time_value);
  228. X       str = asctime(&tm);
  229. X       if (w->clock.font == NULL)
  230. X          w->clock.font = XQueryFont( XtDisplay(w),
  231. X                      XGContextFromGC(
  232. X                       DefaultGCOfScreen(XtScreen(w))) );
  233. X       min_width = XTextWidth(w->clock.font, str, strlen(str)) +
  234. X      2 * w->clock.padding;
  235. X       min_height = w->clock.font->ascent +
  236. X      w->clock.font->descent + 2 * w->clock.padding;
  237. X    }
  238. X    if (w->core.width == 0)
  239. X    w->core.width = min_width;
  240. X    if (w->core.height == 0)
  241. X    w->core.height = min_height;
  242. X
  243. X    myXGCV.foreground = w->clock.fgpixel;
  244. X    myXGCV.background = w->core.background_pixel;
  245. X    if (w->clock.font != NULL)
  246. X        myXGCV.font = w->clock.font->fid;
  247. X    else
  248. X        valuemask &= ~GCFont;    /* use server default font */
  249. X    myXGCV.line_width = 0;
  250. X    w->clock.myGC = XtGetGC((Widget)w, valuemask, &myXGCV);
  251. X
  252. X    valuemask = GCForeground | GCLineWidth ;
  253. X    myXGCV.foreground = w->core.background_pixel;
  254. X    w->clock.EraseGC = XtGetGC((Widget)w, valuemask, &myXGCV);
  255. X
  256. X    myXGCV.foreground = w->clock.Hipixel;
  257. X    w->clock.HighGC = XtGetGC((Widget)w, valuemask, &myXGCV);
  258. X
  259. X    valuemask = GCForeground;
  260. X    myXGCV.foreground = w->clock.Hdpixel;
  261. X    w->clock.HandGC = XtGetGC((Widget)w, valuemask, &myXGCV);
  262. X
  263. X    if (w->clock.update <= 0)
  264. X    w->clock.update = 60;    /* make invalid update's use a default */
  265. X    w->clock.show_second_hand = (w->clock.update <= SECOND_HAND_TIME);
  266. X    w->clock.numseg = 0;
  267. X    w->clock.interval_id = 0;
  268. X}
  269. X
  270. Xstatic void Realize (gw, valueMask, attrs)
  271. X     Widget gw;
  272. X     XtValueMask *valueMask;
  273. X     XSetWindowAttributes *attrs;
  274. X{
  275. X     ClockWidget    w = (ClockWidget) gw;
  276. X#ifdef notdef
  277. X     *valueMask |= CWBitGravity;
  278. X     attrs->bit_gravity = ForgetGravity;
  279. X#endif
  280. X     switch (w->clock.backing_store) {
  281. X     case Always:
  282. X     case NotUseful:
  283. X     case WhenMapped:
  284. X         *valueMask |=CWBackingStore;
  285. X    attrs->backing_store = w->clock.backing_store;
  286. X    break;
  287. X     }
  288. X     XtCreateWindow( gw, InputOutput, (Visual *)CopyFromParent,
  289. X             *valueMask, attrs);
  290. X     Resize(gw);
  291. X}
  292. X
  293. Xstatic void Destroy (gw)
  294. X     Widget gw;
  295. X{
  296. X     ClockWidget w = (ClockWidget) gw;
  297. X     if (w->clock.interval_id) XtRemoveTimeOut (w->clock.interval_id);
  298. X     XtDestroyGC (w->clock.myGC);
  299. X     XtDestroyGC (w->clock.HighGC);
  300. X     XtDestroyGC (w->clock.HandGC);
  301. X     XtDestroyGC (w->clock.EraseGC);
  302. X}
  303. X
  304. Xstatic void Resize (gw) 
  305. X    Widget gw;
  306. X{
  307. X    ClockWidget w = (ClockWidget) gw;
  308. X    /* don't do this computation if window hasn't been realized yet. */
  309. X    if (XtIsRealized(gw) && w->clock.analog) {
  310. X    /* need signed value since Dimension is unsigned */
  311. X    int radius = ((int) min(w->core.width, w->core.height) - (int) (2 * w->clock.padding)) / 2;
  312. X        w->clock.radius = (Dimension) max (radius, 1);
  313. X
  314. X        w->clock.second_hand_length = ((SECOND_HAND_FRACT * w->clock.radius) / 100);
  315. X        w->clock.minute_hand_length = ((MINUTE_HAND_FRACT * w->clock.radius) / 100);
  316. X        w->clock.hour_hand_length = ((HOUR_HAND_FRACT * w->clock.radius) / 100);
  317. X        w->clock.hand_width = ((HAND_WIDTH_FRACT * w->clock.radius) / 100);
  318. X        w->clock.second_hand_width = ((SECOND_WIDTH_FRACT * w->clock.radius) / 100);
  319. X
  320. X        w->clock.centerX = w->core.width / 2;
  321. X        w->clock.centerY = w->core.height / 2;
  322. X    }
  323. X}
  324. X
  325. X/* ARGSUSED */
  326. Xstatic void Redisplay (gw, event, region)
  327. X    Widget gw;
  328. X    XEvent *event;        /* unused */
  329. X    Region region;        /* unused */
  330. X{
  331. X    ClockWidget w = (ClockWidget) gw;
  332. X    if (w->clock.analog) {
  333. X    if (w->clock.numseg != 0)
  334. X        erase_hands (w, (struct tm *) 0);
  335. X        DrawClockFace(w);
  336. X    } else {
  337. X    w->clock.prev_time_string[0] = '\0';
  338. X    }
  339. X    clock_tic((caddr_t)w, (XtIntervalId)0);
  340. X}
  341. X
  342. X/* ARGSUSED */
  343. Xstatic void clock_tic(client_data, id)
  344. X        caddr_t client_data;
  345. X        XtIntervalId *id;
  346. X{
  347. X        ClockWidget w = (ClockWidget)client_data;    
  348. X    struct tm *localtime();
  349. X    struct tm tm; 
  350. X    long    time_value;
  351. X    char    *time_ptr;
  352. X        register Display *dpy = XtDisplay(w);
  353. X        register Window win = XtWindow(w);
  354. X        int i;    
  355. X
  356. X    if (id || !w->clock.interval_id)
  357. X        w->clock.interval_id =
  358. X        XtAppAddTimeOut( XtWidgetToApplicationContext( (Widget) w),
  359. X                w->clock.update*1000, clock_tic, (caddr_t)w );
  360. X    (void) time(&time_value);
  361. X    tm = *localtime(&time_value);
  362. X    /*
  363. X     * Beep on the half hour; double-beep on the hour.
  364. X     */
  365. X    if (w->clock.beeped && (tm.tm_min != 30) && (tm.tm_min != 0)
  366. X                        && (tm.tm_min != 45) && (tm.tm_min != 15))
  367. X       w->clock.beeped = FALSE;
  368. X
  369. X    if (w->clock.chime == TRUE) {
  370. X        if (((tm.tm_min == 30) || (tm.tm_min == 0)) 
  371. X        && (!w->clock.beeped)) {
  372. X        w->clock.beeped = TRUE;
  373. X        XBell(dpy, 50);    
  374. X        if (tm.tm_min == 0)
  375. X          XBell(dpy, 50);
  376. X        }
  377. X    }
  378. X
  379. X/* Included */
  380. X        if (!w->clock.beeped)
  381. X       switch (tm.tm_min)
  382. X       {
  383. X       case 0:
  384. X          if (w->clock.hour_sound)
  385. X             play_sound(w->clock.hour_sound, w->clock.volume);
  386. X          if (w->clock.chime_sound)
  387. X          {
  388. X             if (!(i=(tm.tm_hour%12)))
  389. X                i = 12;
  390. X             for ( ; i--; )
  391. X                play_sound(w->clock.chime_sound, w->clock.volume);
  392. X          }
  393. X          w->clock.beeped = TRUE;
  394. X          break;
  395. X       case 15:
  396. X          if (w->clock.quarter_past_sound)
  397. X             play_sound(w->clock.quarter_past_sound, w->clock.volume);
  398. X          w->clock.beeped = TRUE;
  399. X          break;
  400. X       case 30:
  401. X          if (w->clock.half_past_sound)
  402. X             play_sound(w->clock.half_past_sound, w->clock.volume);
  403. X          w->clock.beeped = TRUE;
  404. X          break;
  405. X       case 45:
  406. X          if (w->clock.quarter_of_sound)
  407. X             play_sound(w->clock.quarter_of_sound, w->clock.volume);
  408. X          w->clock.beeped = TRUE;
  409. X          break;
  410. X       }
  411. X/* End included */
  412. X
  413. X    if( w->clock.analog == FALSE ) {
  414. X        int    clear_from;
  415. X        int i, len, prev_len;
  416. X
  417. X        time_ptr = asctime(&tm);
  418. X        len = strlen (time_ptr);
  419. X        if (time_ptr[len - 1] == '\n') time_ptr[--len] = '\0';
  420. X        prev_len = strlen (w->clock.prev_time_string);
  421. X        for (i = 0; ((i < len) && (i < prev_len) && 
  422. X                 (w->clock.prev_time_string[i] == time_ptr[i])); i++);
  423. X        strcpy (w->clock.prev_time_string+i, time_ptr+i);
  424. X
  425. X        XDrawImageString (dpy, win, w->clock.myGC,
  426. X                  (2+w->clock.padding +
  427. X                   XTextWidth (w->clock.font, time_ptr, i)),
  428. X                  2+w->clock.font->ascent+w->clock.padding,
  429. X                  time_ptr + i, len - i);
  430. X        /*
  431. X         * Clear any left over bits
  432. X         */
  433. X        clear_from = XTextWidth (w->clock.font, time_ptr, len)
  434. X                 + 2 + w->clock.padding;
  435. X        if (clear_from < w->core.width)
  436. X        XFillRectangle (dpy, win, w->clock.EraseGC,
  437. X            clear_from, 0, w->core.width - clear_from, w->core.height);
  438. X    } else {
  439. X            /*
  440. X             * The second (or minute) hand is sec (or min) 
  441. X             * sixtieths around the clock face. The hour hand is
  442. X             * (hour + min/60) twelfths of the way around the
  443. X             * clock-face.  The derivation is left as an excercise
  444. X             * for the reader.
  445. X             */
  446. X
  447. X            /*
  448. X             * 12 hour clock.
  449. X             */
  450. X            if(tm.tm_hour > 12)
  451. X                tm.tm_hour -= 12;
  452. X
  453. X            erase_hands (w, &tm);
  454. X
  455. X            if (w->clock.numseg == 0 ||
  456. X            tm.tm_min != w->clock.otm.tm_min ||
  457. X            tm.tm_hour != w->clock.otm.tm_hour) {
  458. X                w->clock.segbuffptr = w->clock.segbuff;
  459. X                w->clock.numseg = 0;
  460. X                /*
  461. X                 * Calculate the hour hand, fill it in with its
  462. X                 * color and then outline it.  Next, do the same
  463. X                 * with the minute hand.  This is a cheap hidden
  464. X                 * line algorithm.
  465. X                 */
  466. X                DrawHand(w,
  467. X                w->clock.minute_hand_length, w->clock.hand_width,
  468. X                ((double) tm.tm_min)/60.0
  469. X                );
  470. X                if(w->clock.Hdpixel != w->core.background_pixel)
  471. X                XFillPolygon( dpy,
  472. X                    win, w->clock.HandGC,
  473. X                    w->clock.segbuff, VERTICES_IN_HANDS,
  474. X                    Convex, CoordModeOrigin
  475. X                );
  476. X                XDrawLines( dpy,
  477. X                win, w->clock.HighGC,
  478. X                w->clock.segbuff, VERTICES_IN_HANDS,
  479. X                       CoordModeOrigin);
  480. X                w->clock.hour = w->clock.segbuffptr;
  481. X                DrawHand(w, 
  482. X                w->clock.hour_hand_length, w->clock.hand_width,
  483. X                ((((double)tm.tm_hour) + 
  484. X                    (((double)tm.tm_min)/60.0)) / 12.0)
  485. X                );
  486. X                if(w->clock.Hdpixel != w->core.background_pixel) {
  487. X                  XFillPolygon(dpy,
  488. X                       win, w->clock.HandGC,
  489. X                       w->clock.hour,
  490. X                       VERTICES_IN_HANDS,
  491. X                       Convex, CoordModeOrigin
  492. X                       );
  493. X                }
  494. X                XDrawLines( dpy,
  495. X                       win, w->clock.HighGC,
  496. X                       w->clock.hour, VERTICES_IN_HANDS,
  497. X                       CoordModeOrigin );
  498. X
  499. X                w->clock.sec = w->clock.segbuffptr;
  500. X            }
  501. X            if (w->clock.show_second_hand == TRUE) {
  502. X                w->clock.segbuffptr = w->clock.sec;
  503. X                DrawSecond(w,
  504. X                w->clock.second_hand_length - 2, 
  505. X                w->clock.second_hand_width,
  506. X                w->clock.minute_hand_length + 2,
  507. X                ((double) tm.tm_sec)/60.0
  508. X                );
  509. X                if(w->clock.Hdpixel != w->core.background_pixel)
  510. X                XFillPolygon( dpy,
  511. X                    win, w->clock.HandGC,
  512. X                    w->clock.sec,
  513. X                    VERTICES_IN_HANDS -2,
  514. X                    Convex, CoordModeOrigin
  515. X                );
  516. X                XDrawLines( dpy,
  517. X                       win, w->clock.HighGC,
  518. X                       w->clock.sec,
  519. X                       VERTICES_IN_HANDS-1,
  520. X                       CoordModeOrigin
  521. X                        );
  522. X
  523. X            }
  524. X            w->clock.otm = tm;
  525. X        }
  526. X}
  527. X
  528. Xstatic erase_hands (w, tm)
  529. XClockWidget    w;
  530. Xstruct tm    *tm;
  531. X{
  532. X    /*
  533. X     * Erase old hands.
  534. X     */
  535. X    if(w->clock.numseg > 0) {
  536. X    Display    *dpy;
  537. X    Window    win;
  538. X
  539. X    dpy = XtDisplay (w);
  540. X    win = XtWindow (w);
  541. X    if (w->clock.show_second_hand == TRUE) {
  542. X        XDrawLines(dpy, win,
  543. X        w->clock.EraseGC,
  544. X        w->clock.sec,
  545. X        VERTICES_IN_HANDS-1,
  546. X        CoordModeOrigin);
  547. X        if(w->clock.Hdpixel != w->core.background_pixel) {
  548. X        XFillPolygon(dpy,
  549. X            win, w->clock.EraseGC,
  550. X            w->clock.sec,
  551. X            VERTICES_IN_HANDS-2,
  552. X            Convex, CoordModeOrigin
  553. X            );
  554. X        }
  555. X    }
  556. X    if(!tm || tm->tm_min != w->clock.otm.tm_min ||
  557. X          tm->tm_hour != w->clock.otm.tm_hour)
  558. X     {
  559. X        XDrawLines( dpy, win,
  560. X            w->clock.EraseGC,
  561. X            w->clock.segbuff,
  562. X            VERTICES_IN_HANDS,
  563. X            CoordModeOrigin);
  564. X        XDrawLines( dpy, win,
  565. X            w->clock.EraseGC,
  566. X            w->clock.hour,
  567. X            VERTICES_IN_HANDS,
  568. X            CoordModeOrigin);
  569. X        if(w->clock.Hdpixel != w->core.background_pixel) {
  570. X        XFillPolygon( dpy, win,
  571. X                   w->clock.EraseGC,
  572. X                  w->clock.segbuff, VERTICES_IN_HANDS,
  573. X                  Convex, CoordModeOrigin);
  574. X        XFillPolygon( dpy, win,
  575. X                   w->clock.EraseGC,
  576. X                  w->clock.hour,
  577. X                  VERTICES_IN_HANDS,
  578. X                  Convex, CoordModeOrigin);
  579. X        }
  580. X    }
  581. X    }
  582. X}
  583. X
  584. X/*
  585. X * DrawLine - Draws a line.
  586. X *
  587. X * blank_length is the distance from the center which the line begins.
  588. X * length is the maximum length of the hand.
  589. X * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating
  590. X * how far around the circle (clockwise) from high noon.
  591. X *
  592. X * The blank_length feature is because I wanted to draw tick-marks around the
  593. X * circle (for seconds).  The obvious means of drawing lines from the center
  594. X * to the perimeter, then erasing all but the outside most pixels doesn't
  595. X * work because of round-off error (sigh).
  596. X */
  597. Xstatic void DrawLine(w, blank_length, length, fraction_of_a_circle)
  598. XClockWidget w;
  599. XDimension blank_length;
  600. XDimension length;
  601. Xdouble fraction_of_a_circle;
  602. X{
  603. X    double dblank_length = (double)blank_length, dlength = (double)length;
  604. X    double angle, cosangle, sinangle;
  605. X    double cos();
  606. X    double sin();
  607. X    int cx = w->clock.centerX, cy = w->clock.centerY, x1, y1, x2, y2;
  608. X
  609. X    /*
  610. X     *  A full circle is 2 PI radians.
  611. X     *  Angles are measured from 12 o'clock, clockwise increasing.
  612. X     *  Since in X, +x is to the right and +y is downward:
  613. X     *
  614. X     *    x = x0 + r * sin(theta)
  615. X     *    y = y0 - r * cos(theta)
  616. X     *
  617. X     */
  618. X    angle = TWOPI * fraction_of_a_circle;
  619. X    cosangle = cos(angle);
  620. X    sinangle = sin(angle);
  621. X
  622. X    /* break this out so that stupid compilers can cope */
  623. X    x1 = cx + (int)(dblank_length * sinangle);
  624. X    y1 = cy - (int)(dblank_length * cosangle);
  625. X    x2 = cx + (int)(dlength * sinangle);
  626. X    y2 = cy - (int)(dlength * cosangle);
  627. X    SetSeg(w, x1, y1, x2, y2);
  628. X}
  629. X
  630. X/*
  631. X * DrawHand - Draws a hand.
  632. X *
  633. X * length is the maximum length of the hand.
  634. X * width is the half-width of the hand.
  635. X * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating
  636. X * how far around the circle (clockwise) from high noon.
  637. X *
  638. X */
  639. Xstatic void DrawHand(w, length, width, fraction_of_a_circle)
  640. XClockWidget w;
  641. XDimension length, width;
  642. Xdouble fraction_of_a_circle;
  643. X{
  644. X
  645. X    register double angle, cosangle, sinangle;
  646. X    register double ws, wc;
  647. X    Position x, y, x1, y1, x2, y2;
  648. X    double cos();
  649. X    double sin();
  650. X
  651. X    /*
  652. X     *  A full circle is 2 PI radians.
  653. X     *  Angles are measured from 12 o'clock, clockwise increasing.
  654. X     *  Since in X, +x is to the right and +y is downward:
  655. X     *
  656. X     *    x = x0 + r * sin(theta)
  657. X     *    y = y0 - r * cos(theta)
  658. X     *
  659. X     */
  660. X    angle = TWOPI * fraction_of_a_circle;
  661. X    cosangle = cos(angle);
  662. X    sinangle = sin(angle);
  663. X    /*
  664. X     * Order of points when drawing the hand.
  665. X     *
  666. X     *        1,4
  667. X     *        / \
  668. X     *           /   \
  669. X     *          /     \
  670. X     *        2 ------- 3
  671. X     */
  672. X    wc = width * cosangle;
  673. X    ws = width * sinangle;
  674. X    SetSeg(w,
  675. X           x = w->clock.centerX + round(length * sinangle),
  676. X           y = w->clock.centerY - round(length * cosangle),
  677. X           x1 = w->clock.centerX - round(ws + wc), 
  678. X           y1 = w->clock.centerY + round(wc - ws));  /* 1 ---- 2 */
  679. X    /* 2 */
  680. X    SetSeg(w, x1, y1, 
  681. X           x2 = w->clock.centerX - round(ws - wc), 
  682. X           y2 = w->clock.centerY + round(wc + ws));  /* 2 ----- 3 */
  683. X
  684. X    SetSeg(w, x2, y2, x, y);    /* 3 ----- 1(4) */
  685. X}
  686. X
  687. X/*
  688. X * DrawSecond - Draws the second hand (diamond).
  689. X *
  690. X * length is the maximum length of the hand.
  691. X * width is the half-width of the hand.
  692. X * offset is direct distance from center to tail end.
  693. X * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating
  694. X * how far around the circle (clockwise) from high noon.
  695. X *
  696. X */
  697. Xstatic void DrawSecond(w, length, width, offset, fraction_of_a_circle)
  698. XClockWidget w;
  699. XDimension length, width, offset;
  700. Xdouble fraction_of_a_circle;
  701. X{
  702. X
  703. X    register double angle, cosangle, sinangle;
  704. X    register double ms, mc, ws, wc;
  705. X    register int mid;
  706. X    Position x, y;
  707. X    double cos();
  708. X    double sin();
  709. X
  710. X    /*
  711. X     *  A full circle is 2 PI radians.
  712. X     *  Angles are measured from 12 o'clock, clockwise increasing.
  713. X     *  Since in X, +x is to the right and +y is downward:
  714. X     *
  715. X     *    x = x0 + r * sin(theta)
  716. X     *    y = y0 - r * cos(theta)
  717. X     *
  718. X     */
  719. X    angle = TWOPI * fraction_of_a_circle;
  720. X    cosangle = cos(angle);
  721. X    sinangle = sin(angle);
  722. X    /*
  723. X     * Order of points when drawing the hand.
  724. X     *
  725. X     *        1,5
  726. X     *        / \
  727. X     *           /   \
  728. X     *          /     \
  729. X     *        2<       >4
  730. X     *          \     /
  731. X     *           \   /
  732. X     *        \ /
  733. X     *    -     3
  734. X     *    |
  735. X     *    |
  736. X     *   offset
  737. X     *    |
  738. X     *    |
  739. X     *    -     + center
  740. X     */
  741. X
  742. X    mid = (length + offset) / 2;
  743. X    mc = mid * cosangle;
  744. X    ms = mid * sinangle;
  745. X    wc = width * cosangle;
  746. X    ws = width * sinangle;
  747. X    /*1 ---- 2 */
  748. X    SetSeg(w,
  749. X           x = w->clock.centerX + round(length * sinangle),
  750. X           y = w->clock.centerY - round(length * cosangle),
  751. X           w->clock.centerX + round(ms - wc),
  752. X           w->clock.centerY - round(mc + ws) );
  753. X    SetSeg(w, w->clock.centerX + round(offset *sinangle),
  754. X           w->clock.centerY - round(offset * cosangle), /* 2-----3 */
  755. X           w->clock.centerX + round(ms + wc), 
  756. X           w->clock.centerY - round(mc - ws));
  757. X    w->clock.segbuffptr->x = x;
  758. X    w->clock.segbuffptr++->y = y;
  759. X    w->clock.numseg ++;
  760. X}
  761. X
  762. Xstatic void SetSeg(w, x1, y1, x2, y2)
  763. XClockWidget w;
  764. Xint x1, y1, x2, y2;
  765. X{
  766. X    w->clock.segbuffptr->x = x1;
  767. X    w->clock.segbuffptr++->y = y1;
  768. X    w->clock.segbuffptr->x = x2;
  769. X    w->clock.segbuffptr++->y = y2;
  770. X    w->clock.numseg += 2;
  771. X}
  772. X
  773. X/*
  774. X *  Draw the clock face (every fifth tick-mark is longer
  775. X *  than the others).
  776. X */
  777. Xstatic void DrawClockFace(w)
  778. XClockWidget w;
  779. X{
  780. X    register int i;
  781. X    register int delta = (w->clock.radius - w->clock.second_hand_length) / 3;
  782. X    
  783. X    w->clock.segbuffptr = w->clock.segbuff;
  784. X    w->clock.numseg = 0;
  785. X    for (i = 0; i < 60; i++)
  786. X        DrawLine(w, ( (i % 5) == 0 ? 
  787. X                 w->clock.second_hand_length :
  788. X                 (w->clock.radius - delta) ),
  789. X             w->clock.radius, ((double) i)/60.);
  790. X    /*
  791. X     * Go ahead and draw it.
  792. X     */
  793. X    XDrawSegments(XtDisplay(w), XtWindow(w),
  794. X              w->clock.myGC, (XSegment *) &(w->clock.segbuff[0]),
  795. X              w->clock.numseg/2);
  796. X    
  797. X    w->clock.segbuffptr = w->clock.segbuff;
  798. X    w->clock.numseg = 0;
  799. X}
  800. X
  801. Xstatic int round(x)
  802. Xdouble x;
  803. X{
  804. X    return(x >= 0.0 ? (int)(x + .5) : (int)(x - .5));
  805. X}
  806. X
  807. X/* ARGSUSED */
  808. Xstatic Boolean SetValues (gcurrent, grequest, gnew)
  809. X    Widget gcurrent, grequest, gnew;
  810. X{
  811. X      ClockWidget current = (ClockWidget) gcurrent;
  812. X      ClockWidget new = (ClockWidget) gnew;
  813. X      Boolean redisplay = FALSE;
  814. X      XtGCMask valuemask;
  815. X      XGCValues    myXGCV;
  816. X
  817. X      /* first check for changes to clock-specific resources.  We'll accept all
  818. X         the changes, but may need to do some computations first. */
  819. X
  820. X      if (new->clock.update != current->clock.update) {
  821. X      if (current->clock.interval_id)
  822. X          XtRemoveTimeOut (current->clock.interval_id);
  823. X      if (XtIsRealized(new))
  824. X          new->clock.interval_id = XtAppAddTimeOut( 
  825. X                                         XtWidgetToApplicationContext(gnew),
  826. X                     new->clock.update*1000,
  827. X                         clock_tic, (caddr_t)gnew);
  828. X
  829. X      new->clock.show_second_hand =(new->clock.update <= SECOND_HAND_TIME);
  830. X      }
  831. X
  832. X      if (new->clock.padding != current->clock.padding)
  833. X       redisplay = TRUE;
  834. X
  835. X      if (new->clock.analog != current->clock.analog)
  836. X       redisplay = TRUE;
  837. X
  838. X       if (new->clock.font != current->clock.font)
  839. X       redisplay = TRUE;
  840. X
  841. X      if ((new->clock.fgpixel != current->clock.fgpixel)
  842. X          || (new->core.background_pixel != current->core.background_pixel)) {
  843. X          valuemask = GCForeground | GCBackground | GCFont | GCLineWidth;
  844. X      myXGCV.foreground = new->clock.fgpixel;
  845. X      myXGCV.background = new->core.background_pixel;
  846. X          myXGCV.font = new->clock.font->fid;
  847. X      myXGCV.line_width = 0;
  848. X      XtDestroyGC (current->clock.myGC);
  849. X      new->clock.myGC = XtGetGC(gcurrent, valuemask, &myXGCV);
  850. X      redisplay = TRUE;
  851. X          }
  852. X
  853. X      if (new->clock.Hipixel != current->clock.Hipixel) {
  854. X          valuemask = GCForeground | GCLineWidth;
  855. X      myXGCV.foreground = new->clock.fgpixel;
  856. X          myXGCV.font = new->clock.font->fid;
  857. X      myXGCV.line_width = 0;
  858. X      XtDestroyGC (current->clock.HighGC);
  859. X      new->clock.HighGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV);
  860. X      redisplay = TRUE;
  861. X          }
  862. X
  863. X      if (new->clock.Hdpixel != current->clock.Hdpixel) {
  864. X          valuemask = GCForeground;
  865. X      myXGCV.foreground = new->clock.fgpixel;
  866. X      XtDestroyGC (current->clock.HandGC);
  867. X      new->clock.HandGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV);
  868. X      redisplay = TRUE;
  869. X          }
  870. X
  871. X      if (new->core.background_pixel != current->core.background_pixel) {
  872. X          valuemask = GCForeground | GCLineWidth;
  873. X      myXGCV.foreground = new->core.background_pixel;
  874. X      myXGCV.line_width = 0;
  875. X      XtDestroyGC (current->clock.EraseGC);
  876. X      new->clock.EraseGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV);
  877. X      redisplay = TRUE;
  878. X      }
  879. X     
  880. X     return (redisplay);
  881. X
  882. X}
  883. E!O!F! Clock.c
  884. echo Clock.h 1>&2
  885. sed -e 's/^X//' > Clock.h <<'E!O!F! Clock.h'
  886. X/*
  887. X* $XConsortium: Clock.h,v 1.28 89/07/20 14:54:38 jim Exp $
  888. X*/
  889. X
  890. X
  891. X/***********************************************************
  892. XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  893. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  894. X
  895. X                        All Rights Reserved
  896. X
  897. XPermission to use, copy, modify, and distribute this software and its 
  898. Xdocumentation for any purpose and without fee is hereby granted, 
  899. Xprovided that the above copyright notice appear in all copies and that
  900. Xboth that copyright notice and this permission notice appear in 
  901. Xsupporting documentation, and that the names of Digital or MIT not be
  902. Xused in advertising or publicity pertaining to distribution of the
  903. Xsoftware without specific, written prior permission.  
  904. X
  905. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  906. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  907. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  908. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  909. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  910. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  911. XSOFTWARE.
  912. X
  913. X******************************************************************/
  914. X
  915. X#ifndef _XawClock_h
  916. X#define _XawClock_h
  917. X
  918. X/***********************************************************************
  919. X *
  920. X * Clock Widget
  921. X *
  922. X ***********************************************************************/
  923. X
  924. X#include <X11/Xmu/Converters.h>
  925. X
  926. X/* Parameters:
  927. X
  928. X Name             Class        RepType        Default Value
  929. X ----             -----        -------        -------------
  930. X analog             Boolean        Boolean        True
  931. X background         Background        Pixel        white
  932. X backingStore         BackingStore    BackingStore    default
  933. X border             BorderColor    Pixel        Black
  934. X borderWidth         BorderWidth    Dimension    1
  935. X chime             Boolean        Boolean        False
  936. X destroyCallback     Callback        Pointer        NULL
  937. X font             Font        XFontStruct*    fixed
  938. X foreground         Foreground        Pixel        black
  939. X hand             Foreground        Pixel        black
  940. X height             Height        Dimension    164
  941. X highlight         Foreground        Pixel        black
  942. X mappedWhenManaged   MappedWhenManaged    Boolean        True
  943. X padding         Margin        int        8
  944. X reverseVideo         ReverseVideo    Boolean        False
  945. X update             Interval        int        60 (seconds)
  946. X width             Width        Dimension    164
  947. X x             Position        Position    0
  948. X y             Position        Position    0
  949. X hourSound           HourSound          String          NULL
  950. X quarterPastSound    QuarterPastSound   String          NULL
  951. X halfPastSound       HalfPastSound      String          NULL
  952. X quarterOfSound      QuarterOfSound     String          NULL
  953. X chimeSound          ChimeSound         String          NULL
  954. X volume              Volume             int             75
  955. X
  956. X*/
  957. X
  958. X/* Resource names used to the clock widget */
  959. X
  960. X        /* color of hands */
  961. X#define XtNhand "hands"
  962. X
  963. X
  964. X        /* Boolean: digital if FALSE */
  965. X#define XtNanalog "analog"
  966. X
  967. X        /* Boolean:  */
  968. X#define XtNchime "chime"
  969. X
  970. X        /* Int: amount of space around outside of clock */
  971. X#define XtNpadding "padding"
  972. X#define XtNhourSound "hourSound"
  973. X#define XtCHourSound "HourSound"
  974. X#define XtNquarterPastSound "quarterPastSound"
  975. X#define XtCQuarterPastSound "QuarterPastSound"
  976. X#define XtNhalfPastSound "halfPastSound"
  977. X#define XtCHalfPastSound "HalfPastSound"
  978. X#define XtNquarterOfSound "quarterOfSound"
  979. X#define XtCQuarterOfSound "QuarterOfSound"
  980. X#define XtNchimeSound "chimeSound"
  981. X#define XtCChimeSound "ChimeSound"
  982. X#define XtNvolume "volume"
  983. X#define XtCVolume "Volume"
  984. X
  985. Xtypedef struct _ClockRec *ClockWidget;  /* completely defined in ClockPrivate.h */
  986. Xtypedef struct _ClockClassRec *ClockWidgetClass;    /* completely defined in ClockPrivate.h */
  987. X
  988. Xextern WidgetClass clockWidgetClass;
  989. X
  990. X#endif /* _XawClock_h */
  991. X/* DON'T ADD STUFF AFTER THIS #endif */
  992. E!O!F! Clock.h
  993. echo ClockP.h 1>&2
  994. sed -e 's/^X//' > ClockP.h <<'E!O!F! ClockP.h'
  995. X/*
  996. X* $XConsortium: ClockP.h,v 1.19 89/12/06 15:23:06 kit Exp $
  997. X*/
  998. X
  999. X
  1000. X/***********************************************************
  1001. XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  1002. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  1003. X
  1004. X                        All Rights Reserved
  1005. X
  1006. XPermission to use, copy, modify, and distribute this software and its 
  1007. Xdocumentation for any purpose and without fee is hereby granted, 
  1008. Xprovided that the above copyright notice appear in all copies and that
  1009. Xboth that copyright notice and this permission notice appear in 
  1010. Xsupporting documentation, and that the names of Digital or MIT not be
  1011. Xused in advertising or publicity pertaining to distribution of the
  1012. Xsoftware without specific, written prior permission.  
  1013. X
  1014. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1015. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1016. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1017. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1018. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1019. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1020. XSOFTWARE.
  1021. X
  1022. X******************************************************************/
  1023. X
  1024. X#ifndef _XawClockP_h
  1025. X#define _XawClockP_h
  1026. X
  1027. X#include <X11/Xos.h>        /* Needed for struct tm. */
  1028. X#include "Clock.h"
  1029. X#include <X11/CoreP.h>
  1030. X
  1031. X#define SEG_BUFF_SIZE        128
  1032. X#define ASCII_TIME_BUFLEN    32    /* big enough for 26 plus slop */
  1033. X
  1034. X/* New fields for the clock widget instance record */
  1035. Xtypedef struct {
  1036. X     Pixel    fgpixel;    /* color index for text */
  1037. X     Pixel    Hipixel;    /* color index for Highlighting */
  1038. X     Pixel    Hdpixel;    /* color index for hands */
  1039. X     XFontStruct    *font;    /* font for text */
  1040. X     GC    myGC;        /* pointer to GraphicsContext */
  1041. X     GC    EraseGC;    /* eraser GC */
  1042. X     GC    HandGC;        /* Hand GC */
  1043. X     GC    HighGC;        /* Highlighting GC */
  1044. X/* start of graph stuff */
  1045. X     int    update;        /* update frequence */
  1046. X     Dimension radius;        /* radius factor */
  1047. X     int    backing_store;    /* backing store type */
  1048. X     Boolean reverse_video;
  1049. X     Boolean chime;
  1050. X     Boolean beeped;
  1051. X     Boolean analog;
  1052. X     Boolean show_second_hand;
  1053. X     Dimension second_hand_length;
  1054. X     Dimension minute_hand_length;
  1055. X     Dimension hour_hand_length;
  1056. X     Dimension hand_width;
  1057. X     Dimension second_hand_width;
  1058. X     Position centerX;
  1059. X     Position centerY;
  1060. X     int    numseg;
  1061. X     int    padding;
  1062. X     XPoint    segbuff[SEG_BUFF_SIZE];
  1063. X     XPoint    *segbuffptr;
  1064. X     XPoint    *hour, *sec;
  1065. X     struct tm  otm ;
  1066. X     XtIntervalId interval_id;
  1067. X     char prev_time_string[ASCII_TIME_BUFLEN];
  1068. X     String          hour_sound;   /* sounds to play at different times */
  1069. X     String          quarter_past_sound;
  1070. X     String          half_past_sound;
  1071. X     String          quarter_of_sound;
  1072. X     String          chime_sound;
  1073. X     int             volume;
  1074. X  } ClockPart;
  1075. X
  1076. X/* Full instance record declaration */
  1077. Xtypedef struct _ClockRec {
  1078. X   CorePart core;
  1079. X   ClockPart clock;
  1080. X   } ClockRec;
  1081. X
  1082. X/* New fields for the Clock widget class record */
  1083. Xtypedef struct {int dummy;} ClockClassPart;
  1084. X
  1085. X/* Full class record declaration. */
  1086. Xtypedef struct _ClockClassRec {
  1087. X   CoreClassPart core_class;
  1088. X   ClockClassPart clock_class;
  1089. X   } ClockClassRec;
  1090. X
  1091. X/* Class pointer. */
  1092. Xextern ClockClassRec clockClassRec;
  1093. X
  1094. X#endif /* _XawClockP_h */
  1095. E!O!F! ClockP.h
  1096. echo Imakefile 1>&2
  1097. sed -e 's/^X//' > Imakefile <<'E!O!F! Imakefile'
  1098. X        DEFINES = -DSUNOS4_1
  1099. X       INCLUDES = -I/usr/demo/SOUND
  1100. X        DEPLIBS = XawClientDepLibs
  1101. XLOCAL_LIBRARIES =  XawClientLibs
  1102. X  SYS_LIBRARIES = -L/usr/demo/SOUND -laudio -lm
  1103. X
  1104. X#ifdef SparcArchitecture
  1105. XSRCS = xclock.c Clock.c transform.c play.c libst.c libsst.c
  1106. XOBJS = xclock.o Clock.o transform.o play.o libst.o libsst.o
  1107. X#else
  1108. XSRCS = xclock.c Clock.c transform.c
  1109. XOBJS = xclock.o Clock.o transform.o
  1110. X#endif
  1111. X
  1112. XComplexProgramTarget(xclock)
  1113. XInstallAppDefaults(XClock)
  1114. E!O!F! Imakefile
  1115. echo Makefile 1>&2
  1116. sed -e 's/^X//' > Makefile <<'E!O!F! Makefile'
  1117. X# Makefile generated by imake - do not edit!
  1118. X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
  1119. X#
  1120. X# The cpp used on this machine replaces all newlines and multiple tabs and
  1121. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  1122. X# for this, but is not always successful.
  1123. X#
  1124. X
  1125. X###########################################################################
  1126. X# Makefile generated from "Imake.tmpl" and <Imakefile>
  1127. X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
  1128. X#
  1129. X# Platform-specific parameters may be set in the appropriate .cf
  1130. X# configuration files.  Site-wide parameters may be set in the file
  1131. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  1132. X#
  1133. X# If your C preprocessor doesn't define any unique symbols, you'll need
  1134. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  1135. X# "make Makefile", "make Makefiles", or "make World").
  1136. X#
  1137. X# If you absolutely can't get imake to work, you'll need to set the
  1138. X# variables at the top of each Makefile as well as the dependencies at the
  1139. X# bottom (makedepend will do this automatically).
  1140. X#
  1141. X
  1142. X###########################################################################
  1143. X# platform-specific configuration parameters - edit sun.cf to change
  1144. X
  1145. XSYSLIBS=-lXt -lX11
  1146. XMWM_DEFINES=-DSHAPE -DOPAQUE
  1147. X
  1148. X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
  1149. X# operating system:  SunOS 4.1
  1150. X
  1151. X###########################################################################
  1152. X# site-specific configuration parameters - edit site.def to change
  1153. X
  1154. X# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
  1155. X
  1156. X            SHELL = /bin/sh
  1157. X
  1158. X              TOP = .
  1159. X      CURRENT_DIR = .
  1160. X
  1161. X               AR = ar cq
  1162. X  BOOTSTRAPCFLAGS =
  1163. X               CC = cc
  1164. X
  1165. X         COMPRESS = compress
  1166. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  1167. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  1168. X          INSTALL = install
  1169. X               LD = ld
  1170. X             LINT = lint
  1171. X      LINTLIBFLAG = -C
  1172. X         LINTOPTS = -axz
  1173. X               LN = ln -s
  1174. X             MAKE = make
  1175. X               MV = mv
  1176. X               CP = cp
  1177. X           RANLIB = ranlib
  1178. X  RANLIBINSTFLAGS =
  1179. X               RM = rm -f
  1180. X     STD_INCLUDES =
  1181. X  STD_CPP_DEFINES =
  1182. X      STD_DEFINES =
  1183. X EXTRA_LOAD_FLAGS =
  1184. X  EXTRA_LIBRARIES =
  1185. X             TAGS = ctags
  1186. X
  1187. X    SHAREDCODEDEF = -DSHAREDCODE
  1188. X         SHLIBDEF = -DSUNSHLIB
  1189. X
  1190. X    PROTO_DEFINES =
  1191. X
  1192. X     INSTPGMFLAGS =
  1193. X
  1194. X     INSTBINFLAGS = -m 0755
  1195. X     INSTUIDFLAGS = -m 4755
  1196. X     INSTLIBFLAGS = -m 0664
  1197. X     INSTINCFLAGS = -m 0444
  1198. X     INSTMANFLAGS = -m 0444
  1199. X     INSTDATFLAGS = -m 0444
  1200. X    INSTKMEMFLAGS = -m 4755
  1201. X
  1202. X          DESTDIR =
  1203. X
  1204. X     TOP_INCLUDES = -I$(INCROOT)
  1205. X
  1206. X      CDEBUGFLAGS = -O
  1207. X        CCOPTIONS = -D_NO_PROTO -DSTRINGS_ALIGNED -DNO_REGEX -DNO_ISDIR -DUSE_RE_COMP -DUSE_GETWD
  1208. X      COMPATFLAGS =
  1209. X
  1210. X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
  1211. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
  1212. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  1213. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  1214. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  1215. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
  1216. X   LDCOMBINEFLAGS = -X -r
  1217. X
  1218. X        MACROFILE = sun.cf
  1219. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  1220. X
  1221. X    IMAKE_DEFINES =
  1222. X
  1223. X         IRULESRC = $(CONFIGDIR)
  1224. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  1225. X
  1226. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  1227. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  1228. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  1229. X
  1230. X###########################################################################
  1231. X# X Window System Build Parameters
  1232. X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  1233. X
  1234. X###########################################################################
  1235. X# X Window System make variables; this need to be coordinated with rules
  1236. X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  1237. X
  1238. X          PATHSEP = /
  1239. X        USRLIBDIR = $(DESTDIR)/usr/lib
  1240. X           BINDIR = $(DESTDIR)/usr/bin/X11
  1241. X          INCROOT = $(DESTDIR)/usr/include
  1242. X     BUILDINCROOT = $(TOP)
  1243. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  1244. X      BUILDINCTOP = ..
  1245. X           INCDIR = $(INCROOT)/X11
  1246. X           ADMDIR = $(DESTDIR)/usr/adm
  1247. X           LIBDIR = $(USRLIBDIR)/X11
  1248. X        CONFIGDIR = $(LIBDIR)/config
  1249. X       LINTLIBDIR = $(USRLIBDIR)/lint
  1250. X
  1251. X          FONTDIR = $(LIBDIR)/fonts
  1252. X         XINITDIR = $(LIBDIR)/xinit
  1253. X           XDMDIR = $(LIBDIR)/xdm
  1254. X           AWMDIR = $(LIBDIR)/awm
  1255. X           TWMDIR = $(LIBDIR)/twm
  1256. X           GWMDIR = $(LIBDIR)/gwm
  1257. X          MANPATH = $(DESTDIR)/usr/man
  1258. X    MANSOURCEPATH = $(MANPATH)/man
  1259. X           MANDIR = $(MANSOURCEPATH)n
  1260. X        LIBMANDIR = $(MANSOURCEPATH)3
  1261. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  1262. X
  1263. X        SOXLIBREV = 4.2
  1264. X          SOXTREV = 4.0
  1265. X         SOXAWREV = 4.0
  1266. X        SOOLDXREV = 4.0
  1267. X         SOXMUREV = 4.0
  1268. X        SOXEXTREV = 4.0
  1269. X
  1270. X       FONTCFLAGS = -t
  1271. X
  1272. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  1273. X
  1274. X            IMAKE = imake
  1275. X           DEPEND = makedepend
  1276. X              RGB = rgb
  1277. X            FONTC = bdftosnf
  1278. X        MKFONTDIR = mkfontdir
  1279. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
  1280. X
  1281. X        CONFIGSRC = $(TOP)/config
  1282. X        CLIENTSRC = $(TOP)/clients
  1283. X          DEMOSRC = $(TOP)/demos
  1284. X           LIBSRC = $(TOP)/lib
  1285. X          FONTSRC = $(TOP)/fonts
  1286. X       INCLUDESRC = $(TOP)/X11
  1287. X        SERVERSRC = $(TOP)/server
  1288. X          UTILSRC = $(TOP)/util
  1289. X        SCRIPTSRC = $(UTILSRC)/scripts
  1290. X       EXAMPLESRC = $(TOP)/examples
  1291. X       CONTRIBSRC = $(TOP)/../contrib
  1292. X           DOCSRC = $(TOP)/doc
  1293. X           RGBSRC = $(TOP)/rgb
  1294. X        DEPENDSRC = $(UTILSRC)/makedepend
  1295. X         IMAKESRC = $(CONFIGSRC)
  1296. X         XAUTHSRC = $(LIBSRC)/Xau
  1297. X          XLIBSRC = $(LIBSRC)/X
  1298. X           XMUSRC = $(LIBSRC)/Xmu
  1299. X       TOOLKITSRC = $(LIBSRC)/Xt
  1300. X       AWIDGETSRC = $(LIBSRC)/Xaw
  1301. X       OLDXLIBSRC = $(LIBSRC)/oldX
  1302. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  1303. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  1304. X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
  1305. X     EXTENSIONSRC = $(TOP)/extensions
  1306. X
  1307. X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
  1308. X     EXTENSIONLIB =  -lXext
  1309. X
  1310. X          DEPXLIB = $(DEPEXTENSIONLIB)
  1311. X             XLIB = $(EXTENSIONLIB) -lX11
  1312. X
  1313. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  1314. X         XAUTHLIB =  -lXau
  1315. X
  1316. X        DEPXMULIB =
  1317. X           XMULIB = -lXmu
  1318. X
  1319. X       DEPOLDXLIB =
  1320. X          OLDXLIB = -loldX
  1321. X
  1322. X      DEPXTOOLLIB =
  1323. X         XTOOLLIB = -lXt
  1324. X
  1325. X        DEPXAWLIB =
  1326. X           XAWLIB = -lXaw
  1327. X
  1328. X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
  1329. X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
  1330. X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
  1331. X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
  1332. X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
  1333. X
  1334. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  1335. X
  1336. X         DEPLIBS1 = $(DEPLIBS)
  1337. X         DEPLIBS2 = $(DEPLIBS)
  1338. X         DEPLIBS3 = $(DEPLIBS)
  1339. X
  1340. X      USRINCDIR = $(DESTDIR)/usr/include
  1341. X        TESTSRC = $(TOP)/tests
  1342. X    MTOOLKITSRC = $(LIBSRC)/Xt
  1343. X     MWIDGETSRC = $(LIBSRC)/Xm
  1344. X   MRESOURCESRC = $(LIBSRC)/Mrm
  1345. X         UILSRC = $(CLIENTSRC)/uil
  1346. X
  1347. X            UIL = uil
  1348. X
  1349. X          DEPLIBS =
  1350. X
  1351. X         DEPLIBS1 = $(DEPLIBS)
  1352. X         DEPLIBS2 = $(DEPLIBS)
  1353. X         DEPLIBS3 = $(DEPLIBS)
  1354. X
  1355. X          SOXMREV = 1.1
  1356. X         SOMRMREV = 1.1
  1357. X
  1358. X       DEPXMLIB =
  1359. X          XMLIB = -lXm
  1360. X
  1361. XDEPMRESOURCELIB =
  1362. X   MRESOURCELIB = -lMrm
  1363. X
  1364. X      DEPUILLIB = $(USRLIBDIR)/libUil.a
  1365. X         UILLIB =  -lUil
  1366. X  LINTMRESOURCE = $(USRLIBDIR)/llib-lMrm.ln
  1367. XLINTXMWIDGETLIB = $(USRLIBDIR)/llib-lXm.ln
  1368. X     LINTUILLIB = $(USRLIBDIR)/llib-lUil.ln
  1369. X
  1370. X###########################################################################
  1371. X# Imake rules for building libraries, programs, scripts, and data files
  1372. X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
  1373. X
  1374. X###########################################################################
  1375. X# start of Imakefile
  1376. X
  1377. X        DEFINES = -DSUNOS4_1
  1378. X       INCLUDES = -I/usr/demo/SOUND
  1379. X        DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  1380. XLOCAL_LIBRARIES =  $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
  1381. X  SYS_LIBRARIES = -L/usr/demo/SOUND -laudio -lm
  1382. X
  1383. XSRCS = xclock.c Clock.c transform.c play.c libst.c libsst.c
  1384. XOBJS = xclock.o Clock.o transform.o play.o libst.o libsst.o
  1385. X
  1386. X PROGRAM = xclock
  1387. X
  1388. Xall:: xclock
  1389. X
  1390. Xxclock: $(OBJS) $(DEPLIBS)
  1391. X    $(RM) $@
  1392. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
  1393. X
  1394. Xinstall:: xclock
  1395. X    $(INSTALL) -c $(INSTPGMFLAGS)   xclock $(BINDIR)
  1396. X
  1397. Xinstall.man:: xclock.man
  1398. X    $(INSTALL) -c $(INSTMANFLAGS) xclock.man $(MANDIR)/xclock.n
  1399. X
  1400. Xdepend::
  1401. X    $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  1402. X
  1403. Xlint:
  1404. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  1405. Xlint1:
  1406. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  1407. X
  1408. Xclean::
  1409. X    $(RM) $(PROGRAM)
  1410. X
  1411. Xinstall:: XClock.ad
  1412. X    $(INSTALL) -c $(INSTAPPFLAGS) XClock.ad $(XAPPLOADDIR)/XClock
  1413. X
  1414. X###########################################################################
  1415. X# common rules for all Makefiles - do not edit
  1416. X
  1417. Xemptyrule::
  1418. X
  1419. Xclean::
  1420. X    $(RM_CMD) \#*
  1421. X
  1422. XMakefile::
  1423. X    -@if [ -f Makefile ]; then \
  1424. X    echo "    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  1425. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  1426. X    else exit 0; fi
  1427. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  1428. X
  1429. Xtags::
  1430. X    $(TAGS) -w *.[ch]
  1431. X    $(TAGS) -xw *.[ch] > TAGS
  1432. X
  1433. X###########################################################################
  1434. X# empty rules for directories that do not have SUBDIRS - do not edit
  1435. X
  1436. Xinstall::
  1437. X    @echo "install in $(CURRENT_DIR) done"
  1438. X
  1439. Xinstall.man::
  1440. X    @echo "install.man in $(CURRENT_DIR) done"
  1441. X
  1442. XMakefiles::
  1443. X
  1444. Xincludes::
  1445. X
  1446. X###########################################################################
  1447. X# dependencies generated by makedepend
  1448. X
  1449. E!O!F! Makefile
  1450. echo README 1>&2
  1451. sed -e 's/^X//' > README <<'E!O!F! README'
  1452. XI     added      the      sound   things      that         Mike Wagner
  1453. X(wagner@cadillac.siemens.com) added to  "oclock"  to xclock. I  prefer
  1454. X"xclock" over "oclock".
  1455. X
  1456. XRefer to the manual page for former information.
  1457. X
  1458. XMatthias Pfuetzner
  1459. Xpfuetzner@agd.fhg.de
  1460. XJan. 25, 1991
  1461. E!O!F! README
  1462. echo XClock.ad 1>&2
  1463. sed -e 's/^X//' > XClock.ad <<'E!O!F! XClock.ad'
  1464. XXClock.input: false
  1465. E!O!F! XClock.ad
  1466. ======= end of part 01 =========
  1467.             @work:            | Matthias Pfuetzner  |         @home:
  1468.   ZGDV, Wilhelminenstrasse 7  | 6100 Darmstadt, FRG |  Lichtenbergstrasse 73
  1469.     +49 6151 155-164 or -101  \    <- Tel.nr. ->    /     +49 6151 75717
  1470.    pfuetzner@agd.fhg.de    pfuetzner@zgdvda.UUCP    XBR1YD3U@DDATHD21.BITNET
  1471.  
  1472.  
  1473. --
  1474. Dan Heller
  1475. ------------------------------------------------
  1476. O'Reilly && Associates               Zyrcom Inc
  1477. Senior Writer                   President
  1478. argv@ora.com            argv@zipcode.com
  1479.